home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / smix130.zip / SMIX130.DOC < prev    next >
Text File  |  1997-06-06  |  13KB  |  232 lines

  1.                 _____      __    __     ____     __   __
  2.                /  _  \    |  \  /  |   |    |   |  \ /  |
  3.               |  / \__|   |   \/   |    |  |     \  ~  /
  4.               |  \___     |        |    |  |      |   |
  5.                \___  \    |  /\/\  |    |  |      |   |
  6.                __  \  |   |  |  |  |    |  |      |   |
  7.               |  \_/  |   |  |  |  |    |  |     /  ^  \
  8.                \_____/    |__|  |__|   |____|   |__/ \__|
  9.  
  10.                        for Turbo Pascal real mode
  11.  
  12.                               Version 1.30
  13.                     Written by Ethan Brodsky (97/6/6)
  14.          Copyright 1995 by Ethan Brodsky.  All rights reserved.
  15.  
  16. This library is distributed AS IS.  The author specifically disclaims
  17. responsibility for any loss of profit or any consequential, incidental,
  18. or other damages.  SMIX is freeware and is distributed with full source
  19. code, which is copyright by Ethan Brodsky.  You are free to incorporate
  20. the code in full or part into your own programs as long as credit is
  21. given to Ethan Brodsky.  The source code may be distributed in its
  22. original form only, including this documentation and the copyright
  23. notices.
  24.  
  25. ------------------------------------------------------------------------
  26.  
  27. You may have used my SBVOX and SBDSP units.  They both played one VOC
  28. file at a time.  The whole VOC file had to be loaded into conventional
  29. memory, taking valuable memory from a real mode program.
  30.  
  31. SMIX will play up to 8 sounds at one time.  The sounds are stored in
  32. extended memory and copied to a small buffer as needed.  It should work
  33. with any Sound Blaster compatible sound card.  It uses auto-initialized
  34. DMA if it is supported, eliminating clicks between blocks.  If a SB16 is
  35. installed, it will use 16-bit sound output, increasing the sound
  36. quality.  Full Turbo Pascal source is included.
  37.  
  38. The sounds are stored on disk as raw signed 8-bit sample data, at a
  39. sampling rate of 22050 HZ, or the sampling rate specified in the SMIX
  40. source file.  There are two options for usage of XMS:
  41.   1)  Each sound can be stored in its own extended memory block.  This
  42.       allows random allocation and deallocation of sounds.  Each sound
  43.       uses an extended memory handle.  The default HIMEM configuration
  44.       has only 32 handles, so the maximum number of sounds that can be
  45.       loaded is 32.  (Less if TSRs or other drivers use handles)  This
  46.       is the default mode.
  47.   2)  All sounds can be loaded into one extended memory block.  Sounds
  48.       can be loaded one at a time, but all sounds must be deallocated
  49.       at once.  Initialize this mode by calling InitSharing before
  50.       allocating any sounds.  Sounds should be allocated and freed as
  51.       usual by using the LoadSound and FreeSound procedures, but all
  52.       extended memory will remain allocated until ShutdownSharing is
  53.       called.
  54.  
  55. In case you are wondering about the three counters displayed by the test
  56. program, the first one counts in the CPU's free time, the second counts
  57. the number of interrupts that have occurred, and the third is the number
  58. of sounds currently being played.  If you have any problems, please tell
  59. me what each counter is doing.
  60.  
  61. This library will work in the real-mode IDE but requires a little work
  62. to get it to work in the protected mode IDE.  By default, the IDE's DPMI
  63. extender uses all extended memory.  The demo requires 200k of extended
  64. memory, and any programs using SMIX require extended memory to hold all
  65. the sounds.  You can decrease the amount of extended memory used by the
  66. IDE by setting the DPMIMEM environment variable:
  67.   SET DPMIMEM=MAXMEM x
  68. where x is the number of kilobytes of extended memory to use for the
  69. IDE.  You will have to find a balance between memory left over for your
  70. program and memory available for IDE use.  (Source code, online help,
  71. compilation...)  It is very important to deallocate extended memory on
  72. program termination.  The run-time library will free the heap, but
  73. extended memory is left allocated.  The handles and memory will be lost
  74. until the next reboot.  It is not enough just to deallocate XMS at the
  75. end of your code, because a run-time error or Halt will stop execution
  76. before the memory has been deallocated.  I would recommend using an exit
  77. procedure to deallocate memory, as demonstrated in the example program.
  78. Make sure that you keep the exit chain intact, or SMIX's exit procedure
  79. will not be called, possibly causing static and a system crash.
  80.  
  81. You can change the sampling rate used for output by changing the
  82. constant at the top of the SMIX source file.  If you decide to do this,
  83. all sound effects must be sampled at the rate you specify, or they will
  84. play at the wrong frequency.  Higher sampling rates will increase CPU
  85. usage.  Do not use a rate larger than 22050 HZ or SMIX will not work on
  86. sound cards older than the SB16.
  87.  
  88. SMIX either uses a raw 8-bit unsigned file format, or in a combined
  89. resource file.  I have included a program that will convert WAV files to
  90. the raw format necessary, and a program to combine raw sound files into
  91. a resource file.  The WAV files must be 8-bit and sampled at 22050 HZ,
  92. or the output will be distorted.  If you have changed the sampling rate
  93. constant in the SMIX source file then the sounds should be sampled at
  94. the rate you have specified.
  95.  
  96. Use the SNDLIB utility included with this package to build sound
  97. resource files.  The syntax for SNDLIB is similar to that of Borland's
  98. TLIB, but it is much more restrictive.  Remember that resources are
  99. identified by their "key", which comes after the filename when adding a
  100. resource.  The key is an 8 character case-insensitive string that is
  101. should be passsed to the load sound function after you have opened the
  102. resource file.
  103.  
  104. The mixing algorithm I use for the SB16 sacrifices volume level for
  105. precision.  This means that the mixed output will be fairly quiet on
  106. 16-bit sounds cards.  However, the SB16 has fairly load output, so it
  107. should come out about right.  If you think that the output is too quiet,
  108. you can disable 16-bit output by passing "0" as the 16-bit DMA channel
  109. to the SB initialization function, ignoring what the detect routine
  110. returns.
  111.  
  112. I have several improvements planned, but I need feedback.  If you are
  113. using my code, I would greatly appreciate it if you would mail me and
  114. tell me about it.  If you have any bug reports, suggestions, or have
  115. made improvements, please tell me!  I have added volume control to the
  116. protected mode libraries, but not this version, since a 32k lookup table
  117. is required. If you want volume control implemented in this version,
  118. tell me!  I also have finished a FM synthesis MIDI music library and am
  119. working on a digital music library, so tell me what you want!
  120.  
  121. This library is freeware, but I would appreciate contributions so I can
  122. continue to buy development kits and upgrade my computer.  You don't
  123. NEED to send me anything, but if you are making money by using this,
  124. please send whatever you feel it is worth.
  125.  
  126. Features:
  127.   * Up to 8 sounds played simultaneously
  128.   * Sampling rate of 22050 HZ (changable at compile-time)
  129.   * Autoinitialized DMA prevents clicking
  130.   * 16-bit sound output increases quality
  131.   * Mixes in the background using less than 5% CPU time
  132.   * Sounds stored in extended memory
  133.   * Sound resource files allow you to store all sounds in one file
  134.  
  135. ------------------------------------------------------------------------
  136.  
  137. There are several ways to contact me:
  138.     E-Mail:  ebrodsky@pobox.com       (Preferred)
  139.              brodskye@cae.wisc.edu
  140.     WWW:     http://www.pobox.com/~ebrodsky/
  141.              http://www.xraylith.wisc.edu/~ebrodsky/
  142.     Phone:   (608) 238-4830
  143.     Mail:
  144.         Ethan Brodsky
  145.       4010 Cherokee Dr.
  146.       Madison, WI 53711
  147.  
  148. Bug fixes and other announcements will be posted in:
  149.     alt.sb.programmer
  150.     comp.archives.msdos.announce
  151.     comp.lang.pascal
  152.     comp.sys.ibm.pc.soundcard.tech
  153.     rec.games.programmer
  154. Up-to-date versions may be downloaded from:
  155.     http://www.pobox.com/~ebrodsky/smix/smix.html
  156.     ftp.simtel.net /pub/simtelnet/msdos/sound/smix*.zip
  157.     x2ftp.oulu.fi /pub/msdos/programming/mxlibs/smix*.zip
  158.  
  159. Revision history:
  160.  0.99a - Initial beta release
  161.  0.99b - Fixed a sound quality problem for sound cards that do not
  162.          support auto-initialized DMA transfers.  Commented the DSP
  163.          initialization commands.
  164.  1.10  - Optimized time-critical code.  Fixed a bug that prevented
  165.          16-bit output under certain circumstances.  Thanks to Douglas
  166.          Kaden from Creative Labs for pointing out that the problem was
  167.          in the address calculation.  Added support for shared extended
  168.          memory block.
  169.  1.11  - Made MixingBlock static to improve efficiency.  Fixed two bugs
  170.          in 8-bit single cycle output.  Improved 8-bit single-cycle
  171.          output quality by removing redundant DSP commands.
  172.  1.15  - Switched to a new mixing algorithm that doesn't reduce sound
  173.          volume on 8-bit sound cards.  Fixed a problem with output on
  174.          Sound Blaster Pros.  Optimized mixing code.  Modified code in
  175.          exit procedure to reset sound card on termination.  Reduced
  176.          CPU utilitization to under 5%.
  177.  1.16  - Fixed a file problem and modified exit procedure code.
  178.  1.17  - Fixed a problem that caused static in the last block of sound
  179.          loaded from an sound files with an odd length.  Thanks to Mike
  180.          Polly for informing me of this problem and helping me resolve
  181.          it.
  182.  1.18  - Fixed a detection problem with sound cards on DMA0.  Added a
  183.          SoundPlaying function to check if a sound is still playing.
  184.  1.19  - Fixed setup for SB16s that use an 8-bit DMA channel for 16-bit
  185.          sound.
  186.  1.20  - Added support for sound resource files.  New WAV2RAW converter
  187.          that correctly converts all conformant WAV files containing the
  188.          correct type of data.
  189.  1.21  - Fixed a problem in loading sounds from resource files that
  190.          caused a "burp" at the end of certain sound files.  Thanks to
  191.          Ron T. Lewis for his assistance in resolving this problem. Also
  192.          fixed a minor bug in the demo program.
  193.  1.25  - Squeezed a few more cycles from mixing routines.  Variable
  194.          sampling rate.  Optimized mixing code.  Added FILE_ID.DIZ for
  195.          BBS use.
  196.  1.26  - Fixed a minor bug in the 8-bit clipping routine, eliminating
  197.          clicking in 8-bit playback.
  198.  1.27  - Discovered a bug in the code generated for LongInt division for
  199.          386 and higher processors.  The TP compiler generates code that
  200.          uses the 32-bit registers, but doesn't preserve them when
  201.          generating code for interrupt handlers.  This caused problems
  202.          with LongInt math in programs using SMIX and with certain TSRs
  203.          (including SmartDrive, resulting in corruption of disk I/O).
  204.          Fixed problem by disabling use of 32-bit instructions inside of
  205.          interrupt handler.  Thanks to Thomas Wehrle for his assistance
  206.          in resolving this problem.  Also fixed minor bugs in WAV2RAW
  207.          and SNDLIB tools.
  208.  1.30  - Fixed a bug in the WAV2RAW converter that caused problems with
  209.          non-typical WAV files.  Removed all floating point math from
  210.          SMIX to avoid linking in unnecssary floating point code.  Fixed
  211.          a minor bug in the initialization routines that prevented SMIX
  212.          from using autoinitialized DMA on sound cards with DSP v2.00.
  213.          Fixed a bug in the XMSMove routine in the XMS unit that
  214.          prevented it from working when the move parameters structure is
  215.          not in the data segment.  Made XMS move parameter structures
  216.          local variables.  Changed LoadSound to a function and added
  217.          error handling.  Made StartSound a function, returning whether
  218.          or not it could play the sound.  Added support for variable
  219.          sampling rates.  Fixed a problem in handling sounds with index
  220.          zero.  Prevented SMIX from installing its exit handler multiple
  221.          times.  Made OpenSoundResourceFile a function.  Made the code
  222.          that fixed LongInt division compile conditionally so it doesn't
  223.          cause problems when compiled in TP6.  Improved mixtest example
  224.          program.  Thanks to Ulrich Doewich, Pawel Veselov (a.k.a. Black
  225.          Angel), Bojan Resnik, Christopher Adams, and Robert Rand for
  226.          their help in improving SMIX.
  227.  
  228. I've been looking to get in with a commercial software company.  If any
  229. companies are interested, write to me at the above address.  Thanks!
  230.  
  231.     Ethan Brodsky
  232.